﻿using aier.business.logic;
using aier.dataaccess.model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace aier.wx.api.selfhost.Controllers
{
    [RoutePrefix("api/Province")]
    public class ProvinceController: ApiController
    {
        public ProvinceBll provinceBll { get; set; }

        /// <summary>
        /// 根据名称查省 名称为空查全部 
        /// 原程序 LocationQueryServiceImpl/queryProvinceByName
        /// </summary>
        /// <param name="provincename">省份名称</param>
        /// <returns></returns>
        [HttpGet]
        [ActionName("QueryProvinceByName")]
        public IHttpActionResult QueryProvinceByName(string provincename)
        {
            List<ProvinceView> provinceViews = provinceBll.QueryProvinceByName(provincename);
            return Ok<List<ProvinceView>>(provinceViews);
        }


        
        /// <summary>
        /// 根据省市区ID查询名称
        /// </summary>
        /// <param name="provinceid"></param>
        /// <param name="cityid"></param>
        /// <param name="areaid"></param>
        /// <returns></returns>
        [Authorize]
        [HttpGet]
        [ActionName("QueryPCANameById")]
        public IHttpActionResult QueryPCANameById(string provinceid, string cityid, string areaid)
        {
            var pcaNames = provinceBll.GetProvinceCityAreaById(provinceid, cityid, areaid);
            return Ok(pcaNames);
        }
    }
}
